<template>
  <div>
    <el-form :model="form" :rules="rules" ref="form" label-width="100px">
      <el-form-item label="房间号" prop="roomNumber">
        <el-input v-model="form.roomNumber" placeholder="请输入房间号"></el-input>
      </el-form-item>

      <el-form-item label="房间标题" prop="roomTitle">
        <el-input v-model="form.roomTitle" placeholder="请输入房间标题"></el-input>
      </el-form-item>

      <el-form-item label="房间设备" prop="roomEquipment">
        <el-checkbox-group v-model="form.roomEquipment">
          <el-checkbox label="空调"></el-checkbox>
          <el-checkbox label="电视"></el-checkbox>
          <el-checkbox label="无线网络"></el-checkbox>
          <el-checkbox label="洗衣机"></el-checkbox>
        </el-checkbox-group>
      </el-form-item>

      <el-form-item label="可住人数" prop="capacity">
        <el-input-number v-model="form.capacity" :min="1" :max="10"></el-input-number>
      </el-form-item>

      <el-form-item label="房间价格" prop="price">
        <el-input-number v-model="form.price" controls-position="right" :min="0" :precision="2"></el-input-number>
      </el-form-item>

      <el-form-item label="房间类型" prop="roomType">
        <el-radio-group v-model="form.roomType">
          <el-radio label="标准间"></el-radio>
          <el-radio label="豪华间"></el-radio>
          <el-radio label="套房"></el-radio>
        </el-radio-group>
      </el-form-item>

      <el-form-item label="有无早餐" prop="breakfast">
        <el-switch v-model="form.breakfast" active-color="#13ce66" inactive-color="#ff4949"></el-switch>
      </el-form-item>

      <el-form-item label="房间状态" prop="status">
        <el-select v-model="form.status" placeholder="请选择房间状态">
          <el-option label="未出租" value="未出租"></el-option>
          <el-option label="已出租" value="已出租"></el-option>
          <el-option label="维修中" value="维修中"></el-option>
        </el-select>
      </el-form-item>

      <el-form-item label="房间图片" prop="image">
        <el-upload
          class="upload-demo"
          action="/api/upload"
          :show-file-list="false"
          :on-success="handleUploadSuccess"
          :before-upload="beforeUpload"
        >
          <el-button size="small" type="primary">点击上传</el-button>
          <div slot="tip" class="el-upload__tip">只能上传jpg/png文件，且不超过2M</div>
        </el-upload>
      </el-form-item>

      <el-form-item label="关联酒店" prop="hotel">
        <el-select v-model="form.hotel" placeholder="请选择关联酒店">
          <el-option label="hotel1" value="hotel1"></el-option>
          <el-option label="hotel2" value="hotel2"></el-option>
          <el-option label="hotel3" value="hotel3"></el-option>
        </el-select>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" @click="submitForm">提交</el-button>
        <el-button @click="resetForm">重置</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>

export default {
  name: 'HotelSystemAdminCc',

  data () {
    return {
      form: {
        roomNumber: '',
        roomTitle: '',
        roomEquipment: [],
        capacity: 1,
        price: 0,
        roomType: '',
        breakfast: false,
        status: '',
        image: '',
        hotel: ''
      }

    }
  },
  methods: {
    submitForm (formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          // 这里可以添加表单提交的逻辑
          alert('提交成功！')
        } else {
          console.log('表单验证失败')
          return false
        }
      })
    }
  }
}
</script>

<style lang="less" scoped>
.hotel-form {
  margin: 50px auto;
  width: 600px;
  padding: 30px;
  border: 1px solid #ccc;
  border-radius: 5px;
}

.form-title {
  text-align: center;
}

.form {
  margin-top: 30px;
}

.el-form-item__label {
  font-weight: bold;
}

.el-form-item__content {
  margin-left: 120px;
  width: 20%;
}

.el-input__inner,
.el-select__input {
  border-radius: 5px;
}

.el-upload__tip {
  margin-left: 120px;
}

.el-button {
  margin-right: 20px;
}

.el-form-item:last-child {
  margin-bottom: 0;
}
</style>
